package profiler.parameters.monitors;

import org.hyperic.sigar.CpuInfo;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;

public class CpuInfoParameter extends GenericParameter {

	private static CpuInfo[] cpuInfo;
	private static String id;
	private static Sigar sigarValue = new Sigar();
	
	private static final double BYTE = 1.0;
	private static final double GIGA = 1073741824.0;
	
	public CpuInfoParameter() throws SigarException {
		super(id, sigarValue);
		cpuInfo = sigarValue.getCpuInfoList();
	}
	
	public String generateReport(){
		String report = "Number of Cpu cores available: " + cpuInfo.length + "\n\n";
		for (int i=0; i < cpuInfo.length; i++){
			report +="Cpu id: " + (i+1) + "\n";
			report += "Cache size: "+cpuInfo[i].getCacheSize()+"\n";
			report += "Velocity: "+cpuInfo[i].getMhz()+ " Mhz/sec\n";
			report += "Total cores: " + cpuInfo[i].getTotalCores() + "cores \n";
			report += "Cores per socket: "+cpuInfo[i].getCoresPerSocket() + " sockets per core\n\n";
		}
		return report;
	}

}
